<template>
  <div>
    <!-- 表格组件 -->
    <el-table :data="books" style="width: 100%">
      <el-table-column prop="id" label="ID"></el-table-column>
      <el-table-column prop="title" label="Title"></el-table-column>
      <el-table-column prop="author" label="Author"></el-table-column>
      <el-table-column prop="copies" label="Copies"></el-table-column>
      <!-- 添加操作列 -->
      <el-table-column label="Actions" width="150">
        <template slot-scope="scope">
          <el-button @click="removeBook(scope.$index)" type="text" size="small">Delete</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <!-- 表单组件 -->
    <el-form :model="newBook" @submit.native.prevent="addBook" style="margin-top: 20px;">
      <el-form-item label="Title">
        <el-input v-model="newBook.title"></el-input>
      </el-form-item>
      <el-form-item label="Author">
        <el-input v-model="newBook.author"></el-input>
      </el-form-item>
      <el-form-item label="Copies">
        <el-input-number v-model="newBook.copies"></el-input-number>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="addBook">Add Book</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  data() {
    return {
      books: [{"id": 1, "title": "Python编程", "author": "John Doe", "copies": 4},
  {"id": 2, "title": "历史的秘密", "author": "Jane Smith", "copies": 3},
  {"id": 3, "title": "宇宙探索", "author": "Emily Brown", "copies": 2},
  {"id": 4, "title": "健康生活", "author": "Mike Johnson", "copies": 5},
  {"id": 5, "title": "数学之美", "author": "Sarah Lee", "copies": 4},
  {"id": 6, "title": "艺术欣赏", "author": "David White", "copies": 3},
  {"id": 7, "title": "编程入门", "author": "Alice Green", "copies": 2},
  {"id": 8, "title": "科幻世界", "author": "Frank Black", "copies": 5},
  {"id": 9, "title": "自然奇观", "author": "Grace Blue", "copies": 4},
  {"id": 10, "title": "音乐之声", "author": "Tom Red", "copies": 3}
        // ... 现有的图书数据
      ],
      newBook: { title: '', author: '', copies: 0 }
    };
  },
  methods: {
    addBook() {
      const newId = this.books.length + 1;
      this.books.push({ id: newId, ...this.newBook });
      this.newBook = { title: '', author: '', copies: 0 }; // 重置表单
    },
    removeBook(index) {
      this.books.splice(index, 1);
    }
    // ... 其他方法
  }
};
</script>

<style scoped>
/* 你的样式 */
</style>